﻿using LibNiconico.NiconicoApi.Extentions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace LibNiconico.NiconicoApi.Alert
{
    /// <summary>
    /// アラートで取得できるストリーム情報
    /// </summary>
    public class NicoAlertStreamInfo
    {



        /// <summary>
        /// タイトル
        /// </summary>
        public string Title { get; private set; }

        /// <summary>
        /// 説明
        /// </summary>
        public string Description { get; private set; }

        /// <summary>
        /// 提供されるコミュニティタイプ
        /// </summary>
        public string ProviderType { get; private set; }
        
        

        /// <summary>
        /// チャンネル or コミュニティId
        /// </summary>
        public string DefaultCommunity { get; private set; }

        


        internal static NicoAlertStreamInfo Parse(XElement element)
        {
            if (element != null)
            {
                var streamInfo = new NicoAlertStreamInfo();

                streamInfo.Title = element.GetElementAsString("title");
                streamInfo.Description = element.GetElementAsString("description");
                streamInfo.ProviderType = element.GetElementAsString("provider_type");
                streamInfo.DefaultCommunity = element.GetElementAsString("default_community");




                return streamInfo;
            }
            else
            {
                return null;
            }
        }
    }


    /// <summary>
    /// コミュニティ情報
    /// </summary>
    public class NicoAlertCommunityInfo
    {
        /// <summary>
        /// コミュニティ名
        /// </summary>
        public string Name { get; private set; }

        /// <summary>
        /// サムネイルURL
        /// </summary>
        public string Thumbnail { get; private set; }


        internal static NicoAlertCommunityInfo Parse(XElement element)
        {
            if (element != null)
            {
                var communityInfo = new NicoAlertCommunityInfo();
                communityInfo.Name = element.GetElementAsString("name");
                communityInfo.Thumbnail = element.GetElementAsString("thumbnail");

                return communityInfo;

            }
            else
            {
                return null;
            }
        }

    }
}
